<?xml version="1.0"?>
<jsp:root 	xmlns:jsp="http://java.sun.com/JSP/Page"
			xmlns:sql="http://java.sun.com/jsp/jstl/sql"
			xmlns:c="http://java.sun.com/jsp/jstl/core" 
			xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
			version="2.1">
	<jsp:directive.page contentType="text/html; charset=UTF-8" />
	<jsp:directive.page isELIgnored="false" />
	<jsp:output omit-xml-declaration="false"
		doctype-root-element="html"
		doctype-public="-//W3C//DTD XHTML 1.1//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd" />
		
		<!-- Carrito  -->
	<jsp:useBean id="userBean" class="es.albarregas.beans.UserBean" scope="session" />
	<jsp:useBean id="listaPedidosBean" class="es.albarregas.beans.PedidoListBean" scope="session" />
	
	<jsp:setProperty property="clausulaWhere" name="listaPedidosBean" value="where user_oid=${userBean.oid} and confirmado=true" />
	  
	<c:if test="${userBean.oid != 0}">
		<c:set var="clausula" 	value=" where user_oid=${userBean.oid} and confirmado=true" />
		<jsp:setProperty property="clausulaWhere" name="listaPedidosBean" value="${clausula}" />
		<c:set var="oidPedido" value="0" />
		<c:set var="totalPedido" value="0"></c:set>
		<c:forEach var="registros" items="${listaPedidosBean.pedido}">
			<c:set var="oidPedido" value="${registros.oid}" />
			<c:set var="totalPedido" value="${registros.total }"></c:set>
			<c:set var="elPedido" value="${registros}" scope="session"></c:set>
		</c:forEach>
		<c:if test="${oidPedido != 0}">
			<jsp:useBean id="listaLineasPedidoBean" class="es.albarregas.beans.LineasPedidoListBean" scope="session" />
			<c:set var="clausula2" value="where pedido_oid=${oidPedido}" />	
			<jsp:setProperty property="clausulaWhere" name="listaLineasPedidoBean" value="${clausula2}" />
		</c:if>		
    </c:if>
		
<div class="row" >
            
            <!--  ==========  -->
            <!--  = Contenido =  -->
            <!--  ==========  -->
            <section class="span12">
                
                <div class="checkout-container">
                    <div class="row">
                    	<div class="span10 offset1">
                    	    
                    	    <!--  ==========  -->
							<!--  = Cabecera =  -->
							<!--  ==========  -->
                    		<header>
                    		    <div class="row">
                    		    	<div class="span2">
                    		    		<img src="images/logo-ikex.png" alt="Ikex Logo"  width="100px" /><br/>
                    		    		<p>Ikex Furniture Store, S.A.</p>
                    		    		<p>C.I.F.: B-0600001</p>
                    		    		<p>Camino Viejo de Mirandilla S/N, Mérida</p>
                    		    	</div>
                    		    	<div class="span6">
                    		    	    <div class="center-align">
                    		    	        <h1><span class="light" style="font-family: arial;">Factura</span> </h1>
                    		    	    </div>
                    		    	</div>
                    		    	<div class="span2">
                    		    	    <div class="right-align">
                    		    	    	<p><span class="light">Factura nº: </span>000${elPedido.oid }</p>
                    		    	    	<jsp:useBean id="now" class="java.util.Date" scope="request" />
                    		    	    	<p>Fecha: <fmt:formatDate value="${now}" pattern="dd.MM.yyyy" /></p>
                    		    	    	<p>Cliente: ${direccionBean.nombre } ${direccionBean.apellidos }</p>
                    		    	    	<p>IVA incluido (21%)</p>
                    		    	    </div>
                    		    	</div>
                    		    </div>
                    		    <c:if test="${listaResultados != null }">
									<ul class="resultados-list">
									<c:forEach items="${listaResultados}" var="current">
										<li><c:out value="${current }"></c:out></li>
									</c:forEach>
									</ul>
								</c:if>
                    		</header>
                    		
                    		
                    		
                    		<!--  =====================  -->
							<!--  = Items del carrito =  -->
							<!--  =====================  -->
							<form action="${pageContext.request.contextPath}/confirm-order" method="post" name="carrito1" id="checkout1">
							<input type="hidden" name="pageid" value="confirmar.jsp" /> <!-- Vble para guardar la url relativa -->
							<input type="hidden" name="oidPedido" value="${elPedido.oid }" />
							<table class="table table-items" >
							    <thead>
							    	<tr>
							    		<th colspan="1">Artículo</th>
							    		<th><div class="align-center">Cantidad</div></th>
							    		<th><div class="align-right">Precio</div></th>
							    		<th><div class="align-right">Subtotal</div></th>
							    	</tr>
							    </thead>
							    <tbody>
							         
       	                        	<c:forEach var="itemCarrito" items="${listaLineasPedidoBean.lineaPedido }">
	       	                        	<tr>
								        	<td class="desc" style="font-family: arial;">${itemCarrito.nombreProducto }</td>
								        	<td class="qty">${itemCarrito.cantidad }</td>
								        	    
								        	<td class="price" style="font-family: arial;">
								        	    <fmt:formatNumber type="currency" currencySymbol="€" value="${itemCarrito.precioUnitario}" />
								        	</td>
								        	<td class="price" style="font-family: arial;">
								        	    <fmt:formatNumber type="currency" currencySymbol="€" value="${itemCarrito.subtotal}" />
								        	</td>
								        </tr>
       	                        	</c:forEach>
							         
							         
							        
							         
							        
   							        <tr>
										<td colspan="2" rowspan="2">
							        	  
							        	</td>
							        	<td class="stronger" style="font-family: arial;">Envío:</td>
							        	<td class="stronger" style="font-family: arial;"><div class="align-right"><fmt:formatNumber type="currency" currencySymbol="€" value="${elPedido.gastosEnvio}"/></div></td>
							        </tr>
							        <tr>
							        	<td class="stronger" style="font-family: arial;">Total:</td>
							        	<td class="stronger" style="font-family: arial;">
							        		<div id="totalDetalleContainer"><div class="size-16 align-right" id="totalDetalle" style="font-family: arial;">
							        			<fmt:formatNumber type="currency" currencySymbol="€" value="${elPedido.total + elPedido.gastosEnvio}" />
						        			</div></div>
					        			</td>
							        </tr>
							      
							    </tbody>
							</table>
							
							<p class="right-align" >
							    <input type="button" onclick="print()" value="IMPRIMIR" class="btn btn-primary higher bold" style="font-family: arial;"/>
							</p>
							</form>
                    	</div>
                    </div>
                </div>
                
                
            </section> <!-- /contenido -->
        
        </div>
</jsp:root>